home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / util / cdity / availmem2.lha / AvailMem2 / src / AvailMem2_mdisp.s < prev    next >
Text File  |  1997-07-01  |  6KB  |  251 lines

  1.  
  2.     machine 68020
  3.  
  4.  
  5.     * program includes
  6.  
  7.     include    "AvailMem2_gui.i"
  8.     include    "AvailMem2.i"
  9.     include    "lvo.i"
  10.  
  11.     incdir    "include:"
  12.  
  13.     include    "exec/types.i"
  14.     include    "exec/funcdef.i"
  15.     include    "intuition/intuition.i"
  16.  
  17.     * program menu defines
  18.  
  19. MENU_PRJ_ABOUT        equ    $f800
  20. MENU_PRJ_HIDE        equ    $f840
  21. MENU_PRJ_QUIT        equ    $f860
  22.  
  23. MENU_STS_RESIZE        equ    $f801
  24. MENU_STS_MODIFYST    equ    $f841
  25. MENU_STS_LOADST        equ    $f881
  26. MENU_STS_SAVEST        equ    $f8a1
  27. MENU_STS_DEFAULTS    equ    $f8c1
  28.  
  29. MENU_NOPICK        equ    $ffff
  30.  
  31.     section    code,code        ;availmem code section
  32.  
  33. _HandleMemoryDisplayMsgs
  34. * * * * * * * * * * * * * * * * * * * * *
  35. *                    *
  36. * Handles memory-display msgs.        *
  37. *                    *
  38. * * * * * * * * * * * * * * * * * * * * *
  39.     movem.l    d0-a6,-(sp)        ;push all registers
  40.  
  41.     clr.l    .prg_MemDisplayClose    ;reset window close variable
  42.     clr.l    .prg_SettingsChanged    ;reset settings variable
  43.  
  44.     tst.l    MemoryDisplayWnd    ;check if memory-display window open
  45.     beq    .no_MemoryDisplayWnd    ;skip if not
  46.  
  47. .MsgLoop_MemoryDisplay
  48.  
  49.     move.l    _GadToolsBase,a6    ;put gadtoolsbase in a6
  50.     move.l    MemoryDisplayWnd,a0    ;get ptr to memory-display window
  51.     move.l    wd_UserPort(a0),a0    ;get window userport
  52.     jsr    _LVOGT_GetIMsg(a6)    ;get any waiting message
  53.     move.l    d0,ptr_TempMsg        ;store msg
  54.     beq    .no_MemoryDisplayWnd    ;if no message, continue looping
  55.  
  56.     move.l    ptr_TempMsg,a4        ;put msg in a4
  57.     move.l    im_Class(a4),d4        ;get msg class
  58.  
  59.     cmp.l    #IDCMP_CLOSEWINDOW,d4    ;check if closegadget was pressed
  60.     bne    .not_IDCMP_CLOSEWINDOW    ;skip if not
  61.  
  62.     st.l    prg_Terminate        ;enable program termination
  63.  
  64.     clr.l    d4            ;reset msg class
  65. .not_IDCMP_CLOSEWINDOW
  66.  
  67.     cmp.l    #IDCMP_CHANGEWINDOW,d4    ;check if window-position changed or if we were re-organized
  68.     bne    .not_IDCMP_CHANGEWINDOW    ;skip if not
  69.  
  70.     move.l    MemoryDisplayWnd,a0    ;put ptr to mem-display window in a4
  71.  
  72.     move.w    wd_LeftEdge(a0),MemoryDisplayLeft
  73.     move.w    wd_TopEdge(a0),MemoryDisplayTop
  74.     move.w    wd_Width(a0),MemoryDisplayWidth
  75.     move.w    wd_Height(a0),d0
  76.     move.b    wd_BorderTop(a0),d1
  77.     ext.w    d1
  78.     sub.w    d1,d0
  79.     move.w    d0,MemoryDisplayHeight
  80.  
  81.     clr.l    d4            ;reset msg class
  82.  
  83. .not_IDCMP_CHANGEWINDOW
  84.  
  85.     cmp.l    #IDCMP_MENUPICK,d4    ;check if menu-item picked
  86.     bne    .not_IDCMP_MENUPICK    ;skip if not
  87.  
  88.     move.w    im_Code(a4),d4        ;put menu selected in d4
  89.  
  90.     cmp.w    #MENU_PRJ_ABOUT,d4    ;check if Menu About was selected
  91.     bne    .no_MENU_PRJ_ABOUT    ;skip if not
  92.  
  93.     lea.l    _AboutBody,a0        ;get about-body text into a0
  94.     lea.l    _AboutGadgets,a1    ;get about-gadget text into a1
  95.     jsr    _ProgramRequest        ;create a program requester
  96.  
  97. .no_MENU_PRJ_ABOUT
  98.  
  99.     cmp.w    #MENU_PRJ_HIDE,d4    ;check if Menu Hide was selected
  100.     bne    .no_MENU_PRJ_HIDE    ;skip if not
  101.  
  102.     st.l    .prg_MemDisplayClose    ;set window close variable
  103.  
  104.     clr.l    d4            ;clear msg class
  105. .no_MENU_PRJ_HIDE
  106.  
  107.     cmp.w    #MENU_PRJ_QUIT,d4    ;check if Menu Quit was selected
  108.     bne    .no_MENU_PRJ_QUIT    ;skip if not
  109.  
  110.     st.l    prg_Terminate        ;set program termination variable
  111.  
  112.     clr.l    d4            ;clear msg class
  113. .no_MENU_PRJ_QUIT
  114.  
  115.     cmp.w    #MENU_STS_RESIZE,d4    ;check if Menu ReSize was selected
  116.     bne    .no_MENU_STS_RESIZE    ;skip if not
  117.  
  118.     tst.l    ResizeWnd        ;check if already open
  119.     bne    .no_MENU_STS_RESIZE    ;skip if so
  120.  
  121.     * install the memdisplay window into resize window
  122.     move.w    MemoryDisplayLeft,ResizeLeft
  123.     move.w    MemoryDisplayTop,ResizeTop
  124.     move.w    MemoryDisplayWidth,ResizeWidth
  125.     move.w    MemoryDisplayHeight,ResizeHeight
  126.  
  127.     jsr    OpenResizeWindow    ;open availmem resize window
  128.     tst.l    d0            ;check if window opened ok
  129.     bne    .Fail            ;bail out if failure
  130.  
  131.     jsr    CloseMemoryDisplayWindow;close main window
  132.  
  133.     bra    .no_MemoryDisplayWnd
  134.  
  135.     clr.l    d4            ;clear msg class
  136. .no_MENU_STS_RESIZE
  137.  
  138.     cmp.w    #MENU_STS_MODIFYST,d4    ;check if Menu Modify was selected
  139.     bne    .no_MENU_STS_MODIFYST    ;skip if not
  140.  
  141.     tst.l    SettingsWnd        ;check if already open
  142.     bne    .SettingsWinOpen    ;skip if so
  143.  
  144.     jsr    OpenSettingsWindow    ;open availmem settings window
  145.     tst.l    d0            ;check if window opened ok
  146.     bne    .Fail            ;bail out if failure
  147.  
  148. .SettingsWinOpen
  149.  
  150.     move.l    _IntuitionBase,a6    ;put intuitonbase in a6
  151.     move.l    SettingsWnd,a0        ;put settingswindow in a0
  152.     jsr    _LVOActivateWindow(a6)    ;activate window
  153.  
  154.     jsr    _SetSettingsGadgets    ;install program preferences
  155.  
  156.     clr.l    d4            ;clear msg class
  157. .no_MENU_STS_MODIFYST
  158.     cmp.w    #MENU_STS_LOADST,d4    ;check if Menu Load was selected
  159.     bne    .no_MENU_STS_LOADST    ;skip if not
  160.  
  161.     jsr    _LoadMainPreferences    ;load new preferences
  162.     move.l    d0,.prg_SettingsChanged    ;set/clr settings variable
  163.     
  164.     clr.l    d4            ;clear msg class
  165. .no_MENU_STS_LOADST
  166.     cmp.w    #MENU_STS_SAVEST,d4    ;check if Menu Save was selected
  167.     bne    .no_MENU_STS_SAVEST    ;skip if not
  168.  
  169.     jsr    _SaveMainPreferences    ;save program preferences
  170.  
  171.     clr.l    d4            ;clear msg class
  172. .no_MENU_STS_SAVEST
  173.  
  174.     cmp.w    #MENU_STS_DEFAULTS,d4    ;check if Menu Reset was selected
  175.     bne    .no_MENU_STS_DEFAULTS    ;skip if not
  176.  
  177.     jsr    _ResetToDefaults
  178.  
  179.     st.l    .prg_SettingsChanged
  180.  
  181.     clr.l    d4            ;clear msg class
  182. .no_MENU_STS_DEFAULTS
  183.  
  184.     clr.l    d4            ;clear msg class
  185. .not_IDCMP_MENUPICK
  186.  
  187.     cmp.w    #IDCMP_GADGETUP,d4
  188.     bne    .no_IDCMP_GADGETUP
  189.  
  190.     move.l    (4).w,a6        ;flush memory
  191.     move.l    #$3000000,d0
  192.     clr.l    d1
  193.     jsr    _LVOAllocVec(a6)
  194.     move.l    d0,a1
  195.     beq    .MemNotAllocated
  196.  
  197.     jsr    _LVOFreeVec(a6)
  198.  
  199. .MemNotAllocated
  200.  
  201. .no_IDCMP_GADGETUP
  202.  
  203.     move.l    _GadToolsBase,a6    ;put gadtoolsbase in a6
  204.     move.l    ptr_TempMsg,a1        ;put tempmsg in a1
  205.     jsr    _LVOGT_ReplyIMsg(a6)    ;reply window msg
  206.  
  207.     bra    .MsgLoop_MemoryDisplay    ;loop message-reader
  208.  
  209. .no_MemoryDisplayWnd
  210.  
  211.     tst.l    .prg_MemDisplayClose    ;check if win should close
  212.     beq    .no_MemDisplayClose    ;skip if it shouldn't
  213.  
  214.     jsr    _CloseGUI        ;close program GUI
  215.  
  216. .no_MemDisplayClose
  217.  
  218.     tst.l    .prg_SettingsChanged    ;check if settings has changed
  219.     beq    .no_NewSettings        ;skip if no new settings
  220.  
  221.     jsr    _CloseGUI        ;close program GUI
  222.     jsr    _RetrieveSettings    ;get the new settings into action
  223.     jsr    _OpenGUI        ;open program GUI up again
  224.     tst.l    d0            ;check if opening succeded
  225.     beq    .Fail            ;bail out if failure
  226.  
  227. .no_NewSettings
  228.  
  229.     movem.l    (sp)+,d0-a6        ;pop all registers
  230.     clr.l    d0            ;set exitcode to FALSE
  231.     rts                ;return
  232.  
  233. .Fail
  234.     movem.l    (sp)+,d0-a6        ;pop all registers
  235.     st.l    d0            ;set exitcode to TRUE
  236.     rts                ;return
  237.  
  238. .prg_MemDisplayClose    ds.l    1
  239. .prg_SettingsChanged    ds.l    1
  240.  
  241.     section    data,data        ;availmem data section
  242.  
  243. * Menu about text
  244.  
  245. _AboutBody        dc.b    "AvailMem v2.0 Copyright © 1996-1997 Jesper Svennevid\n\n"
  246.             dc.b    "This program is email-ware, so if you use it, please\n"
  247.             dc.b    "send me an email:   chip@beer.com\n\n"
  248.             dc.b    "Registered to: UNREGISTERED VERSION",0
  249.  
  250. _AboutGadgets        dc.b    "Ok",0
  251.